package com.handler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//将其作为处理类定义
@ControllerAdvice
//处理异常的类
public class MyExceptionHandler {

    //ExceptionHandler异常处理器
    //空指针异常
    @ExceptionHandler(NullPointerException.class)
    public String nullHandler() {
        return "/err_1.jsp";
    }

    //数据转换异常
    @ExceptionHandler(NumberFormatException.class)
    public String formatHandler() {
        return "/err_2.jsp";
    }
}
